<template>
  <div id="cornerComment" v-if="dialogVisible">
    <div class="cornerComment-in" ref="dialogBox">
      <div class="cornerComment-in-title">
        <span>往届学生</span>
        <span class="el-icon-circle-close close-Btn-line" @click="closePOpup"></span>
      </div>
      <div class="commentBody">
        <div style="display: flex;align-items: center;">
          <SearchModle dataKey="paststudent" @searchFn="searchFn"></SearchModle>
          <p class="numberline toplineBox-right ml-10">总{{ page.total }}条</p>
        </div>
        <!--本体列表，数据 -->
        <div class="table-body">
          <div class="table-body-box">
            <el-table
                ref="multipleTable"
                :data="arryList"
                :stripe="tableStyle.tableStripe"
                :border="tableStyle.tableBorder"
                :height="tableHeight"
                tooltip-effect="dark"
                header-cell-class-name="table-text-c"
                style="width: 100%">
              <el-table-column
                  prop="name"
                  label="姓名"
                  width="90"
                  align="center">
              </el-table-column>
              <el-table-column
                  label="头像"
                  align="center">
                <template slot-scope="scope">
<!--                  <viewerModle type="1" :imgSrc="scope.row.pic"></viewerModle>-->
                  <ImagePreview :src="scope.row.pic" width="40px" height="40px"></ImagePreview>
                </template>
              </el-table-column>
              <el-table-column
                  label="学籍号"
                  align="center">
                <template slot-scope="scope">
                <span v-if="scope.row.student_code">
                {{scope.row.student_code}}
                  </span>
                  <span v-else>未记录</span>
                </template>
              </el-table-column>
              <el-table-column
                  prop="sex"
                  label="性别"
                  align="center">
              </el-table-column>
              <el-table-column
                  prop="enrol_time"
                  label="入校时间"
                  align="center">
              </el-table-column>
              <el-table-column
                  prop="finish_time"
                  label="离校时间"
                  align="center">
              </el-table-column>
              <el-table-column
                  width="100"
                  label="在校状态"
                  align="center">
                <template slot-scope="scope">
                  <!--正常/离校/转校/毕业-->
                  毕业/离校
                </template>
              </el-table-column>
              <el-table-column
                  label="操作"
                  width="100">
                <template slot-scope="scope">
                  <el-button size="small" @click="addStudent(scope.$index)">学生详情</el-button>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </div>
        <!--工具条 分页-->
        <el-col :span="24" class="toolbar">
          <el-pagination
              background
              layout="prev, pager, next"
              :current-page="page.pageindex"
              :total="page.total"
              :page-size="page.pagesize"
              @current-change="handleSizeChange">
          </el-pagination>
        </el-col>
      </div>
      <div class="cornerComment-in-footer">
        <el-button @click="closePOpup" size="small" >确定</el-button>
      </div>
    </div>
    <!--    学生档案-->
    <studentInfoPover :visible.sync="studentInfoVisible" :studentId="studentId" @InitFn="InitFn"></studentInfoPover>
  </div>
</template>

<script>
import {pagination,tableoption} from '@/utils/util.js'
import studentInfoPover from "../archives/studentInfoPover";

export default {
  props: ['visible'], // commoent 学生点评 collection 学生采集
  components: {
    studentInfoPover
  },
  data() {
    return {
      studentInfoVisible: false,
      studentId:0,
      dialogVisible: false,
      arryList: [], // 数据列表
      tableStyle: tableoption,
      // 页数
      page: {
        pageindex: pagination.pageIndex,
        pagesize: pagination.pageSize,
        total: pagination.total
      },
      editForm: {
        p: '',
        name: '', // 	整型 	必填 	1 	- 	名称
        census_register: '', //  	整型 	必填 	1 	- 	户籍所属镇（街）
        town: '' //  	整型 	必填 	1 	- 	户口
      },
      searchForm: {},
      tableHeight: 0
    }
  },
  watch: {
    visible() {
      this.dialogVisible = this.visible
      if(this.visible){
        let n =this;
        this.$nextTick(()=>{
          let height= n.$refs.dialogBox.offsetHeight;  //top 50 1 search 50 page 50 10 footer 50 1
          this.tableHeight = height - (51+50+60+51)
          console.log('height:', height)
        })
        this.InitFn()
      }else{
        this.arryList = [];
      }
    }
  },
  created() {
  },
  methods: {
    // 关闭弹窗
    closePOpup() {
      this.$emit('update:visible', false)
    },
    getJson(option){
      return JSON.parse(JSON.stringify(option))
    },
    addStudent(index){
      this.studentInfoVisible = true;
      this.studentId = this.arryList[index].id;
    },
    // 初始化
    async InitFn () {
      this.searchForm.p = this.page.pageindex;
      let {data} = await this.$fetch(this.api.system.studentBack, this.searchForm);
      if (data && !data.code) {
        this.arryList = data.list.data
        this.page.total = data.list.total
      }
    },
    // 搜索组件
    searchFn(option) {
      this.page.pageindex = 1
      this.searchForm = option
      this.InitFn()
    },
    // 分页
    handleSizeChange (val) {
      this.page.pageindex = val
      this.InitFn()
    },
  },
  mounted() {
  }
}
</script>
<style scoped>
#cornerComment {
  height: 100vh;
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  background: rgba(0, 0, 0, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9;
}

.cornerComment-in {
  width: 80%;
  height: 75%;
  background: #fff;
  display: flex;
  flex-direction: column;
  border-radius: 5px;
}

.cornerComment-in-title {
  height: 50px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #ddd;
  font-size: 24px;
}

.cornerComment-in-title span {
  padding: 0 10px;
}

.cornerComment-in-title span:first-child {
  flex: 1;
  font-size: 16px;
}

.cornerComment-in-footer {
  height: 50px;
  border-top: 1px solid #ddd;
  display: flex;
  align-items: center;
  padding: 0 10px;
  justify-content: center;
}

.commentBody {
  padding: 0 20px;
  flex: 1;
  overflow-y: auto;
}

.close-Btn-line {
  cursor: pointer;
}
</style>


